/* eslint-disable camelcase,@typescript-eslint/no-unused-vars */ // DO NOT EDIT THIS FILE. AUTO-GENERATED BY mobiletto-orm-typedef-gen import { H3Event, H3Error } from "h3"; import { MobilettoOrmSyncError } from "mobiletto-orm-typedef"; export default defineEventHandler(async (event: H3Event) => { return await filterErrors(event, "source.delete", async (event: H3Event) => { return await requireAdminAccountObject(event, "source.delete", async (event: H3Event, session, account) => { const sourceRepo = sourceRepository(); const id = event?.context?.params?.id; if (!id) throw notFound(sourceRepo.typeDef.idFieldName()); try { const source_by_id = await sourceRepo.safeFindById(id); if (source_by_id) { return await sourceRepo.remove(source_by_id); } } catch (e) { if (e instanceof H3Error) throw e; if (e instanceof MobilettoOrmSyncError) { logger.warn(`source.delete: sync error: ${e}`); throw conflict(); } logger.error(`source.delete: unexpected error: ${e}`); throw serverError(); } throw notFound(id); }); }); });